package com.moneywelcome.auth;

import cn.hutool.json.JSONObject;
import com.moneywelcome.baidu.HttpUtil;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;

/**
 * 身份证号码查询认证
 */
@Slf4j
public class IdCardNumberQuery {

    @SneakyThrows
    public static boolean idCardAuth(String cardNumber) {
        String url="http://api.k780.com:88/?app=idcard.get&idcard="+cardNumber+"&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json";
        String authResult = HttpUtil.postGeneralUrl(url, "application/x-www-form-urlencoded", "", "UTF-8");
        log.info("身份证号认证结果：{}",authResult);
        String result = new JSONObject(authResult).getStr("result");
        String status = new JSONObject(result).getStr("status");
        return status!=null&&"ALREADY_ATT".equals(status);
    }
}
